package 二叉树;

/**
 * @author yuank
 * @version 1.0.0
 * @date 2024/12/14 16:08:08
 */
public class BinaryTreeTemplate {
    public int value;
    public BinaryTreeTemplate left;
    public BinaryTreeTemplate right;

    public BinaryTreeTemplate(int value) {
        //其实这里就可以发现 下层的树可以没有,但是向下的指针一定要说明 对象的初始化就是这样的比如说ArrayList
        this.value = value;
        this.left = null;
        this.right = null;
    }

    public static BinaryTreeTemplate createCompleteBinaryTree() {
        BinaryTreeTemplate root = new BinaryTreeTemplate(1);
        root.left = new BinaryTreeTemplate(2);
        root.right = new BinaryTreeTemplate(3);
        root.left.left = new BinaryTreeTemplate(4);
        root.left.right = new BinaryTreeTemplate(5);
        root.right.left = new BinaryTreeTemplate(6);
        root.right.right = new BinaryTreeTemplate(7);
        return root;
    }
}